<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="servlets.message.*"%>
<%@ page import="org.hibernate.SessionFactory"%>
<%@ page import="org.hibernate.Session"%>
<%@ page import="java.util.List"%>
<%@ page import="hibernate.model.*"%>
<%@ page import="hibernate.util.HibernateUtil"%>
<%@ page import="hibernate.method.*"%>
<%@ page import="hibernate.method.UserMethods"%>

<div class="send_message">
	
	<%
						String type = "client";
						SessionFactory sessionFactory = HibernateUtil
								.getSessionAnnotationFactory();
						Session s = sessionFactory.getCurrentSession();
						s.beginTransaction();
						UserMethods u_m = new UserMethods();
						List<User> ulist = u_m.list_by_type(sessionFactory, s, type);
						s.getTransaction().commit();
						if (ulist.size() > 0) {
							for (User u1 : ulist) {
								String username = u1.getUsername();
								int id = u1.getUser_id();
					%> 
					<form action="MessageSend" method="POST" name='formularz'>
		<table>
			<tr>
				<td>Wyślij wiadomość do użytkownika:</td>
				<td>
				<select id="receiver" name="receiver">
						<option value="0" selected>Wybierz użytkownika</option>
						<option value="<%=id%>"><%=username%></option>
						</select>
				</td>
			</tr>
			<tr>
				<td>Temat wiadomości:</td>
				<td><input type="text" id="subject" name="subject"></input></td>
			</tr>
			<tr>
				<td>Treśc wiadomości:</td>
				<td><textarea id="content" name="content" cols="50" rows="10"> </textarea>
				</td>
			</tr>
			<tr>
				<td><input type="submit" value="Wyślij wiadomość" /></td>
			</tr>
		</table>
	</form>
						<%
							}
						
							}
							if (ulist.size() == 0) {
						%> Nie ma zadnych uzytkownikow w bazie
						<%
							}
						%>
				
</div>
